#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2024-05-18 9:53
# @Author  : nedncs
# @File    : toml.py
# @Description : tests
import tomlkit

# 创建toml
# toml = tomlkit.document()
# toml.add("key1", "value1")
# t = tomlkit.table()
# t.add("key2", "value2")
# t.comment("comment")
# t.update({"u1":"uv1"})
# toml.add('table', t)
# with open('cfg.toml', 'wt') as fp:
#     tomlkit.dump(toml, fp)

# 读取toml
# try:
#     with open('cfg.toml', 'rt+') as fp:
#         toml = tomlkit.load(fp)
#         t = toml.get('table')
#         t.update({'u1': '100', 'u2': '200'})
#         tomlkit.dump(toml, fp)
#         if type(toml) == tomlkit.TOMLDocument:
#             print('成功')
# except Exception as e:
#     print("错误：", e)
